﻿using System;
using Newtonsoft.Json.Linq;

namespace Kele.Activity.Helper
{
    public static class StringExtensions
    {


        public static JToken ToJToken(this string json)
        {
            try
            {
                return string.IsNullOrWhiteSpace(json) ? null : JToken.Parse(json);
            }
            catch (Exception)
            {
                return null;
            }
        }

        public static JObject ToJObject(this string json)
        {
            try
            {
                return string.IsNullOrEmpty(json) ? null : JObject.Parse(json);
            }
            catch (Exception)
            {
                return null;
            }
        }

        public static JArray ToJArray(this string json)
        {
            try
            {
              
                return string.IsNullOrEmpty(json) ? new JArray() : JArray.Parse(json);
            }
            catch (Exception)
            {
                return new JArray();
            }


        }
    }
}
